标签: gradient

iPhone SDK:如何绘制具有半透明渐变和阴影的圆角矩形

我正在尝试通过为我的应用程序手动创建部分UI来绘制iPhone(在本例中为图形).基本上,我想绘制一个带圆角的矩形,一个阴影和一个半透明渐变作为矩形的填充.这是我的photoshop模型的屏幕截图: alt text http://img36.imageshack.us/img36/6097/picture1nvf.png

我已经有了使用CALayer创建一个带阴影的实心圆角矩形,但为了让形状和阴影显示,我必须设置一个背景颜色,这不允许我让我半透明渐变是图层的唯一填充.

我现在一直在研究这个问题,并阅读了整个Core Animation编程指南,但我没有取得任何进一步的进展.我觉得答案就在我的鼻子底下.

我错过了什么?

PSI知道我可能会使用一个图像文件来完成这个,但我正在尝试这样做,因为我想学习,有一天我想用这个做一些更高级的动画.

gradient core-animation core-graphics shadows quartz-graphics

0
推荐指数
1
解决办法
8065
查看次数

自定义渐变按钮 - 无法看到文本

我正在制作一个带有渐变效果的自定义按钮.我能够设置渐变效果,但我看不到文字.我哪里错了?

class CustomButton extends JButton {   
    Color color1, color2;   

    public CustomButton(String text, Color color1, Color color2) {   
        super(text);   
        this.color1 = color1;   
        this.color2 = color2;   
        setOpaque(false);   
        setSize(new Dimension(450, 350));
        setForeground(Color.white);
        setText(text);
        setContentAreaFilled(false);
    }   

    protected void paintComponent(Graphics g) {    
        super.paintComponent(g);
        int width = getWidth();   
        int height = getHeight();   

        GradientPaint paint = new GradientPaint(0, 0, color1, width, height,
                color2, true);
        Graphics2D g2d = (Graphics2D)g;
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                RenderingHints.VALUE_ANTIALIAS_ON);   
        Paint oldPaint = g2d.getPaint();
        g2d.setPaint(paint);
        g2d.fillRect(0, 0, width, height);
        g2d.drawString("Button 1", getWidth()/2, 10);
        g2d.setPaint(oldPaint);
    }   
}  
Run Code Online (Sandbox Code Playgroud)

注意:我允许用户在运行时更改颜色.根据更改的颜色,我相应地设置背景.

java swing gradient jbutton

0
推荐指数
1
解决办法
2593
查看次数

在背景颜色上应用渐变CSS

我希望有一个坚实的背景颜色,并在其上面有一个具有一定不透明度的渐变.这样它似乎是一种背景颜色,在它上面有一个渐变的效果.

这是我的HTML:

<article>
    <a href="" class="article">
      <h2>Title<i></i></h2>
      <img src="images/media-examples/pic1.jpg">
    </a>
</article>
Run Code Online (Sandbox Code Playgroud)

我想将它应用于标题以创建这样的东西:

在此输入图像描述

css gradient opacity css3

0
推荐指数
1
解决办法
1011
查看次数

使用HTML5画布创建渐变颜色选择(所有可能的RGB颜色)

是否可以为线性颜色选择器增加包含所有可能的RGB颜色(仅红色,绿色,蓝色 - 无alpha值)的线性渐变.

到目前为止,我有以下梯度尝试过,但它不会包含所有的值rgb(0,0,0)rgb(255,255,255):

var grd = ctx.createLinearGradient(0, 0, width, 0);
grd.addColorStop(0,     'red');
grd.addColorStop(1 / 6, 'orange');
grd.addColorStop(2 / 6, 'yellow');
grd.addColorStop(3 / 6, 'green')
grd.addColorStop(4 / 6, 'aqua');
grd.addColorStop(5 / 6, 'blue');
grd.addColorStop(1,     'purple');
Run Code Online (Sandbox Code Playgroud)

任何帮助都非常感谢.

gradient canvas colors color-space html5-canvas

0
推荐指数
1
解决办法
4065
查看次数

UIBezierPath和渐变iOS

我有值的路径,我想制作这个渐变.

这是代码:

    CGContextRef context = UIGraphicsGetCurrentContext();

    CGContextSetStrokeColorWithColor(context, [[UIColor colorWithRed:245.0/255.0 green:245.0/255.0 blue:171.0/255.0 alpha:0.6] CGColor]);
    CGContextSetFillColorWithColor(context, [[UIColor colorWithRed:245.0/255.0 green:245.0/255.0 blue:171.0/255.0 alpha:0.6] CGColor]);



    UIBezierPath *aPath = [UIBezierPath bezierPath];
    [aPath moveToPoint:CGPointMake(30.0, 100.0)];


    [aPath addLineToPoint:CGPointMake(200.0, 120.0)];
    [aPath addLineToPoint:CGPointMake(300, 210)];
    [aPath addLineToPoint:CGPointMake(300, 420)];
    [aPath addLineToPoint:CGPointMake(30, 420.0)];
    [aPath addLineToPoint:CGPointMake(30, 100.0)];

    [aPath closePath];
    [aPath fill];
Run Code Online (Sandbox Code Playgroud)

有没有指出这个代码的问题?

gradient ios uibezierpath

0
推荐指数
1
解决办法
3038
查看次数

如何绘制对角线渐变?

如何绘制三种颜色的对角线渐变?

这是一个例子:

il mio gradiente

delphi gradient

0
推荐指数
1
解决办法
803
查看次数

CSS - 使用类的渐变"边框"

我正在做一个项目,我希望设计"顺畅".为此,我使用CSS渐变.但是,我不确切知道如何实现我想要的.我的CSS代码如下:

#wrapper .midcontainer
{
 width: 1000px;
 margin: 20px auto;
}

#wrapper .midcontainer .mid
{
 width: 980px;
 background: #2d2929;
 position: relative;
}

#wrapper .midcontainer .mid .left
{
 background: #2d2929;
 background: -webkit-linear-gradient(right, #2d2929, #e0e0e0);
 background: -o-linear-gradient(right, #2d2929, #e0e0e0);
 background: -moz-linear-gradient(right, #2d2929, #e0e0e0);
 background: linear-gradient(right, #2d2929, #e0e0e0);
 width: 10px;
 height: 100%;
 position: absolute;
 left: -10px;
}

#wrapper .midcontainer .mid .right
{
 background: #2d2929;
 background: -webkit-linear-gradient(left, #2d2929, #e0e0e0);
 background: -o-linear-gradient(left, #2d2929, #e0e0e0);
 background: -moz-linear-gradient(left, #2d2929, #e0e0e0);
 background: linear-gradient(left, #2d2929, #e0e0e0);
 width: 10px;
 height: 100%; …
Run Code Online (Sandbox Code Playgroud)

html css gradient

0
推荐指数
1
解决办法
109
查看次数

PIL:生成垂直渐变图像

在Android中,我使用以下代码来生成所需的渐变背景:

<gradient
    android:angle="90"
    android:startColor="#40000000"
    android:endColor="#00000000"
    android:type="linear" />
Run Code Online (Sandbox Code Playgroud)

背景从上到下从浅到暗。我想知道如何在带有PIL的Python中执行相同的操作,因为我需要对另一个用Python编写的程序具有相同的效果。

python gradient python-imaging-library

0
推荐指数
2
解决办法
1636
查看次数

如何在Android中将可绘制形状渐变应用于android.support.v7.widget.CardView

我无法将背景渐变设置为android.support.v7.widget.CardView

使用app:cardBackgroundColor="@somecolor"此我只设置背景色,而不是可绘制的资源文件

<android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:cardBackgroundColor="@drawable/bg"> // not working in CardView

</android.support.v7.widget.CardView>
Run Code Online (Sandbox Code Playgroud)

bg.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
    <gradient android:angle="45" android:startColor="@android:color/black"
        android:endColor="@android:color/black"
        android:centerColor="@android:color/holo_red_dark"
        android:centerX="4"
        />
</shape>
Run Code Online (Sandbox Code Playgroud)

android gradient drawable android-cardview

0
推荐指数
1
解决办法
5574
查看次数

带有渐变蒙版的CSS垂直滚动字幕

我试图在完整的出血背景上创建一个垂直滚动的选框.滚动文本将包含在页面的中心,并且必须在顶部和底部的渐变不透明蒙版后面传递.

我可以在顶部或底部应用渐变蒙版,但不能同时应用两者.

有没有办法只用CSS/HTML做到这一点?

请参阅应用于容器底部的不透明蒙版 - 目标是在容器的顶部和底部获取该蒙版.

https://jsfiddle.net/appxe0g8/37/

HTML

<div class="microsoft container">
<p class="marquee">ONE<br><br>TWO<br><br>THREE<br><br>FOUR<br><br>FIVE<br><br>SIX.</p>
Run Code Online (Sandbox Code Playgroud)

animation gradient mask opacity css3

0
推荐指数
1
解决办法
1037
查看次数